package com.sanrenzu.chunbo.adapter;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.sanrenzu.chunbo.R;
import com.sanrenzu.chunbo.bean.zxb.DianJiTuPianBean;

import java.util.List;

/**
 * Created by My on 2016/9/1.
 */
public class XiangQingListViewAdapter extends BaseAdapter {

    private List<DianJiTuPianBean> list = null;
    private Context context;
    private LayoutInflater inflater;

    public XiangQingListViewAdapter(Context context, List<DianJiTuPianBean> list) {
        this.context = context;
        this.list = list;
        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView( int position, View convertView, ViewGroup parent) {
        Log.i("TAG","----------->gitview");
        mViewHolder mHolder = null;
        if(convertView==null){
            convertView = inflater.inflate(R.layout.adapter_xiangqing,parent,false);
            mHolder = new mViewHolder(convertView);
            convertView.setTag(mHolder);
        }else {
            mHolder = (mViewHolder) convertView.getTag();
        }
        Glide.with(context).load(list.get(position).getPicUrl()+"").into(mHolder.xiangqing_image_adapter);
        return convertView;
    }

    class mViewHolder {
        ImageView xiangqing_image_adapter;

        public mViewHolder(View convertView) {
            xiangqing_image_adapter = (ImageView) convertView.findViewById(R.id.xiangqing_image_adapter);

        }
    }
}
